package com.example.booksystem.demos.web.dao;

import com.example.booksystem.demos.web.model.Book;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

@Component
public class bookDao {
    public List<Book> mockData(int n) {
        List<Book> list = new ArrayList<>(n);
        for (int i = 0; i < n; i++) {
            Book book = new Book();
            book.setId(i);
            book.setBookName("图书"+i);
            book.setAuthor("作者"+i);
            book.setCount(new Random().nextInt(200));
            book.setPrice(new BigDecimal(new Random().nextInt(100)));
            book.setPublish("出版社"+i);
            book.setStatus(i%5==0?2:1);
            list.add(book);
        }
        return list;
    }
}
